{% extends "common/base.html" %}

{% block title %}更改 Webdav - {{ block.Super }}{% endblock %}

{% block content %}
<div class="row">
    <div class="col-lg-12">
        <div class="row">
            <div class="col-lg-12">
                <ol class="breadcrumb">
                    <li><a href="/">控制台</a></li>
                    <li class="active"><span>我的信息</span></li>
                </ol>
                <h1>更改 Webdav</h1>
            </div>
        </div>

        <div class="row">
            <div class="col-lg-12">
                <div class="main-box clearfix">
                    <header class="main-box-header clearfix">
                        <div class="pull-left">
                            <h2>更改 Webdav</h2>
                        </div>
                    </header>

                    <div class="main-box-body clearfix">
                        <form role="form" class="fs-form">
                            <div class="form-group">
                                <label for="newname">账号</label>
                                <input type="text" 
                                    class="form-control" 
                                    id="wnewname"
                                    placeholder="请输入账号" 
                                    readonly
                                    value="{{ wusername }}">
                            </div>
            
                            <div class="form-group">
                                <label for="pass">新密码</label>
                                <input type="password" 
                                    class="form-control" 
                                    id="pass"
                                    placeholder="请输入新密码" 
                                    name="pass" 
                                    value="">
                            </div>
            
                            <div class="form-group">
                                <button type="button" class="btn btn-success js-save-btn">确认更改</button>
                            </div>
                        </form>

                    </div>
                </div>
            </div>

        </div>

    </div>
</div>
{% endblock %}

{% block script %}
{{ block.Super }}

<script type="text/javascript">
;(function($) {
    "use strict";
    
    // 保存
    $(".js-save-btn").click(function(e) {
        e.stopPropagation;
        e.preventDefault;

        var pass = $("#pass").val();

        var url = '/profile/webdav';
        $.post(url, {
            pass: pass,
        }, function(data) {
            if (data.code == 0) {
                layer.msg(data.message);
                
                setTimeout(function() {
                    window.location.reload();
                }, 1500);
            } else {
                layer.msg(data.message);
            }
        }).fail(function (xhr, status, info) {
            layer.msg("请求失败");
        });
    });
})(jQuery);
</script>
{% endblock %}
